package com.projet.glb2r.Objet;

import java.util.List;

import com.projet.glb2r.R;
import com.projet.glb2r.Activite.ActiviteProduitFacture;
import com.projet.glb2r.Activite.ActiviteTacheFacture;
import com.projet.glb2r.R.id;
import com.projet.glb2r.R.layout;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;

public class ObjetClientAdapter extends BaseAdapter{
	private List<ObjetClient> listeClient;
	private LayoutInflater inflater;
	private Context context;
	
	
	public void setClient(List<ObjetClient> listeClient) {
		this.listeClient = listeClient;
	}

	public ObjetClientAdapter(Context context, List<ObjetClient> listeClient) {
		this.listeClient = listeClient;
		this.context = context;
		this.inflater = LayoutInflater.from(context);
		
	}

	public int getCount() {
		return listeClient.size();
	}

	public Object getItem(int position) {
		return listeClient.get(position);
	}

	public long getItemId(int position) {
		return listeClient.get(position).getID();
	}
	
	private class ViewHolder {
		public TextView tvnom;
		public TextView tvPrenom;
		public TextView tvnum_telephone;
	}

	public View getView(final int position, View view, ViewGroup viewGroup) {
		final ViewHolder holder;
		
		if (view == null) {
			holder = new ViewHolder();
			view = inflater.inflate(R.layout.item_client, null);

			holder.tvnom = (TextView) view
					.findViewById(R.id.textViewNom);
			holder.tvPrenom = (TextView) view
					.findViewById(R.id.textViewPrenom);
			holder.tvnum_telephone = (TextView) view
					.findViewById(R.id.textViewTelephone);

			view.setTag(holder);
		} else {
			holder = (ViewHolder) view.getTag();
		}
		
		holder.tvnom.setText(listeClient.get(position).getNom() );
		holder.tvPrenom.setText(listeClient.get(position).getPrenom());
		holder.tvnum_telephone.setText(listeClient.get(position).getTelephone());
		
		return view;
	}
	
}
